﻿// -----------------------------------------------------------------------
// <copyright file="Motorcycle.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex03.GarageLogic
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public enum eLicenseType
    {
        A,
        A1,
        AA,
        B1
    }

    internal sealed class Motorcycle : Vehicle
    {
        private const int k_NumberOfTires = 2;
        private const float k_MaxAirPressure = 31f;
        private const float k_MaxFuelTankCapacity = 7f;
        private const float k_MaxBatteryLife = 2.2f;
        private const eTypeOfFuel k_TypeFuel = eTypeOfFuel.Octan95;

        private int m_EngineCapacityCc;
        private eLicenseType m_LicenseType;

        internal Motorcycle(string i_Model, string i_PlateNum, List<Tire> i_Tires, EnergySource i_EnergySource, int i_EngineCapacity, eLicenseType i_LicenseType)
        {
            this.ModulName = i_Model;
            this.LicensePlate = i_PlateNum;
            this.TireCollection = i_Tires;
            this.SourceOfEnergy = i_EnergySource;
            this.CalculatePercentEnergyLeft();
            this.m_EngineCapacityCc = i_EngineCapacity;
            this.m_LicenseType = i_LicenseType;
        }
   
        public static int NumOfTires 
        {
            get { return k_NumberOfTires; }
        }

        internal static float MaxAirPressure
        {
            get { return k_MaxAirPressure; }
        }

        internal static float MaxFuelTankCapacity 
        {
            get { return k_MaxFuelTankCapacity; }
        }

        internal static float MaxBatteryLife
        {
            get { return k_MaxBatteryLife; }
        }

        internal static eTypeOfFuel TpyeFuel
        {
            get { return k_TypeFuel; }
        }

        public int EngineCapacity
        {
            get { return this.m_EngineCapacityCc; }
        }

        public eLicenseType LicenseType
        {
            get { return this.m_LicenseType; }
        }

        internal override void GetVehicleData(ref StringBuilder o_VehicleData)
        {
            base.GetVehicleData(ref o_VehicleData);
            o_VehicleData.AppendFormat("{0}Motorcycle engine capacity: {1}{0}Motorcycle license type: {2}{0}", Environment.NewLine, this.EngineCapacity.ToString(), this.LicenseType.ToString());
        }

        public static eLicenseType ConvertToLicenseTypeMotocycle(string i_typeLicence)
        {
            eLicenseType usersInputEnum = (eLicenseType)Enum.Parse(typeof(eLicenseType), i_typeLicence);
            if (Enum.IsDefined(typeof(eLicenseType), usersInputEnum) == false)
            {
                throw new ArgumentException("There is no such option");
            }

            return usersInputEnum;
        }
    }
}
